using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Medianamik.Core.DAL.SubSonicDAL
{
	/// <summary>
	/// Strongly-typed collection for the PropertyX class.
	/// </summary>
    [Serializable]
	public partial class PropertyXCollection : ActiveList<PropertyX, PropertyXCollection>
	{	   
		public PropertyXCollection() {}
        
        /// <summary>
		/// Filters an existing collection based on the set criteria. This is an in-memory filter
		/// Thanks to developingchris for this!
        /// </summary>
        /// <returns>PropertyXCollection</returns>
		public PropertyXCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                PropertyX o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        switch (w.Comparison)
                        {
                            case SubSonic.Comparison.Equals:
                                if (!val.Equals(w.ParameterValue))
                                {
                                    remove = true;
                                }
                                break;
                        }
                    }
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }
		
		
	}
	/// <summary>
	/// This is an ActiveRecord class which wraps the medianamik_Property table.
	/// </summary>
	[Serializable]
	public partial class PropertyX : ActiveRecord<PropertyX>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public PropertyX()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}
		
		private void InitSetDefaults() { SetDefaults(); }
		
		public PropertyX(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}
        
		public PropertyX(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}
		 
		public PropertyX(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}
		
		protected static void SetSQLProps() { GetTableSchema(); }
		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}
		}
		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("medianamik_Property", TableType.Table, DataService.GetInstance("MedianamikProvider"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarPropertyId = new TableSchema.TableColumn(schema);
				colvarPropertyId.ColumnName = "PropertyId";
				colvarPropertyId.DataType = DbType.Guid;
				colvarPropertyId.MaxLength = 0;
				colvarPropertyId.AutoIncrement = false;
				colvarPropertyId.IsNullable = false;
				colvarPropertyId.IsPrimaryKey = true;
				colvarPropertyId.IsForeignKey = false;
				colvarPropertyId.IsReadOnly = false;
				
						colvarPropertyId.DefaultSetting = @"(newid())";
				colvarPropertyId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPropertyId);
				
				TableSchema.TableColumn colvarTypeId = new TableSchema.TableColumn(schema);
				colvarTypeId.ColumnName = "TypeId";
				colvarTypeId.DataType = DbType.Guid;
				colvarTypeId.MaxLength = 0;
				colvarTypeId.AutoIncrement = false;
				colvarTypeId.IsNullable = false;
				colvarTypeId.IsPrimaryKey = false;
				colvarTypeId.IsForeignKey = true;
				colvarTypeId.IsReadOnly = false;
				colvarTypeId.DefaultSetting = @"";
				
					colvarTypeId.ForeignKeyTableName = "medianamik_Type";
				schema.Columns.Add(colvarTypeId);
				
				TableSchema.TableColumn colvarName = new TableSchema.TableColumn(schema);
				colvarName.ColumnName = "Name";
				colvarName.DataType = DbType.String;
				colvarName.MaxLength = 50;
				colvarName.AutoIncrement = false;
				colvarName.IsNullable = false;
				colvarName.IsPrimaryKey = false;
				colvarName.IsForeignKey = false;
				colvarName.IsReadOnly = false;
				colvarName.DefaultSetting = @"";
				colvarName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarName);
				
				TableSchema.TableColumn colvarHaveTooltip = new TableSchema.TableColumn(schema);
				colvarHaveTooltip.ColumnName = "HaveTooltip";
				colvarHaveTooltip.DataType = DbType.Boolean;
				colvarHaveTooltip.MaxLength = 0;
				colvarHaveTooltip.AutoIncrement = false;
				colvarHaveTooltip.IsNullable = false;
				colvarHaveTooltip.IsPrimaryKey = false;
				colvarHaveTooltip.IsForeignKey = false;
				colvarHaveTooltip.IsReadOnly = false;
				
						colvarHaveTooltip.DefaultSetting = @"((0))";
				colvarHaveTooltip.ForeignKeyTableName = "";
				schema.Columns.Add(colvarHaveTooltip);
				
				TableSchema.TableColumn colvarIsLanguageNeutral = new TableSchema.TableColumn(schema);
				colvarIsLanguageNeutral.ColumnName = "IsLanguageNeutral";
				colvarIsLanguageNeutral.DataType = DbType.Boolean;
				colvarIsLanguageNeutral.MaxLength = 0;
				colvarIsLanguageNeutral.AutoIncrement = false;
				colvarIsLanguageNeutral.IsNullable = false;
				colvarIsLanguageNeutral.IsPrimaryKey = false;
				colvarIsLanguageNeutral.IsForeignKey = false;
				colvarIsLanguageNeutral.IsReadOnly = false;
				
						colvarIsLanguageNeutral.DefaultSetting = @"((0))";
				colvarIsLanguageNeutral.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsLanguageNeutral);
				
				TableSchema.TableColumn colvarIsRequired = new TableSchema.TableColumn(schema);
				colvarIsRequired.ColumnName = "IsRequired";
				colvarIsRequired.DataType = DbType.Boolean;
				colvarIsRequired.MaxLength = 0;
				colvarIsRequired.AutoIncrement = false;
				colvarIsRequired.IsNullable = false;
				colvarIsRequired.IsPrimaryKey = false;
				colvarIsRequired.IsForeignKey = false;
				colvarIsRequired.IsReadOnly = false;
				
						colvarIsRequired.DefaultSetting = @"((0))";
				colvarIsRequired.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsRequired);
				
				TableSchema.TableColumn colvarIsUnique = new TableSchema.TableColumn(schema);
				colvarIsUnique.ColumnName = "IsUnique";
				colvarIsUnique.DataType = DbType.Boolean;
				colvarIsUnique.MaxLength = 0;
				colvarIsUnique.AutoIncrement = false;
				colvarIsUnique.IsNullable = false;
				colvarIsUnique.IsPrimaryKey = false;
				colvarIsUnique.IsForeignKey = false;
				colvarIsUnique.IsReadOnly = false;
				
						colvarIsUnique.DefaultSetting = @"((0))";
				colvarIsUnique.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsUnique);
				
				TableSchema.TableColumn colvarValidationRegex = new TableSchema.TableColumn(schema);
				colvarValidationRegex.ColumnName = "ValidationRegex";
				colvarValidationRegex.DataType = DbType.String;
				colvarValidationRegex.MaxLength = 1024;
				colvarValidationRegex.AutoIncrement = false;
				colvarValidationRegex.IsNullable = true;
				colvarValidationRegex.IsPrimaryKey = false;
				colvarValidationRegex.IsForeignKey = false;
				colvarValidationRegex.IsReadOnly = false;
				colvarValidationRegex.DefaultSetting = @"";
				colvarValidationRegex.ForeignKeyTableName = "";
				schema.Columns.Add(colvarValidationRegex);
				
				TableSchema.TableColumn colvarGroupName = new TableSchema.TableColumn(schema);
				colvarGroupName.ColumnName = "GroupName";
				colvarGroupName.DataType = DbType.String;
				colvarGroupName.MaxLength = 50;
				colvarGroupName.AutoIncrement = false;
				colvarGroupName.IsNullable = true;
				colvarGroupName.IsPrimaryKey = false;
				colvarGroupName.IsForeignKey = false;
				colvarGroupName.IsReadOnly = false;
				colvarGroupName.DefaultSetting = @"";
				colvarGroupName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarGroupName);
				
				TableSchema.TableColumn colvarFlags = new TableSchema.TableColumn(schema);
				colvarFlags.ColumnName = "Flags";
				colvarFlags.DataType = DbType.Int32;
				colvarFlags.MaxLength = 0;
				colvarFlags.AutoIncrement = false;
				colvarFlags.IsNullable = false;
				colvarFlags.IsPrimaryKey = false;
				colvarFlags.IsForeignKey = false;
				colvarFlags.IsReadOnly = false;
				
						colvarFlags.DefaultSetting = @"((0))";
				colvarFlags.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFlags);
				
				TableSchema.TableColumn colvarMedianamikControlId = new TableSchema.TableColumn(schema);
				colvarMedianamikControlId.ColumnName = "MedianamikControlId";
				colvarMedianamikControlId.DataType = DbType.Guid;
				colvarMedianamikControlId.MaxLength = 0;
				colvarMedianamikControlId.AutoIncrement = false;
				colvarMedianamikControlId.IsNullable = true;
				colvarMedianamikControlId.IsPrimaryKey = false;
				colvarMedianamikControlId.IsForeignKey = true;
				colvarMedianamikControlId.IsReadOnly = false;
				colvarMedianamikControlId.DefaultSetting = @"";
				
					colvarMedianamikControlId.ForeignKeyTableName = "medianamik_MedianamikControl";
				schema.Columns.Add(colvarMedianamikControlId);
				
				TableSchema.TableColumn colvarMedianamikControlWidth = new TableSchema.TableColumn(schema);
				colvarMedianamikControlWidth.ColumnName = "MedianamikControlWidth";
				colvarMedianamikControlWidth.DataType = DbType.AnsiString;
				colvarMedianamikControlWidth.MaxLength = 10;
				colvarMedianamikControlWidth.AutoIncrement = false;
				colvarMedianamikControlWidth.IsNullable = true;
				colvarMedianamikControlWidth.IsPrimaryKey = false;
				colvarMedianamikControlWidth.IsForeignKey = false;
				colvarMedianamikControlWidth.IsReadOnly = false;
				colvarMedianamikControlWidth.DefaultSetting = @"";
				colvarMedianamikControlWidth.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMedianamikControlWidth);
				
				TableSchema.TableColumn colvarMedianamikControlHeight = new TableSchema.TableColumn(schema);
				colvarMedianamikControlHeight.ColumnName = "MedianamikControlHeight";
				colvarMedianamikControlHeight.DataType = DbType.Int32;
				colvarMedianamikControlHeight.MaxLength = 0;
				colvarMedianamikControlHeight.AutoIncrement = false;
				colvarMedianamikControlHeight.IsNullable = true;
				colvarMedianamikControlHeight.IsPrimaryKey = false;
				colvarMedianamikControlHeight.IsForeignKey = false;
				colvarMedianamikControlHeight.IsReadOnly = false;
				colvarMedianamikControlHeight.DefaultSetting = @"";
				colvarMedianamikControlHeight.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMedianamikControlHeight);
				
				TableSchema.TableColumn colvarPosition = new TableSchema.TableColumn(schema);
				colvarPosition.ColumnName = "Position";
				colvarPosition.DataType = DbType.Int16;
				colvarPosition.MaxLength = 0;
				colvarPosition.AutoIncrement = false;
				colvarPosition.IsNullable = false;
				colvarPosition.IsPrimaryKey = false;
				colvarPosition.IsForeignKey = false;
				colvarPosition.IsReadOnly = false;
				
						colvarPosition.DefaultSetting = @"((0))";
				colvarPosition.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPosition);
				
				TableSchema.TableColumn colvarPrimaryPropertyId = new TableSchema.TableColumn(schema);
				colvarPrimaryPropertyId.ColumnName = "PrimaryPropertyId";
				colvarPrimaryPropertyId.DataType = DbType.Guid;
				colvarPrimaryPropertyId.MaxLength = 0;
				colvarPrimaryPropertyId.AutoIncrement = false;
				colvarPrimaryPropertyId.IsNullable = true;
				colvarPrimaryPropertyId.IsPrimaryKey = false;
				colvarPrimaryPropertyId.IsForeignKey = true;
				colvarPrimaryPropertyId.IsReadOnly = false;
				colvarPrimaryPropertyId.DefaultSetting = @"";
				
					colvarPrimaryPropertyId.ForeignKeyTableName = "medianamik_Property";
				schema.Columns.Add(colvarPrimaryPropertyId);
				
				TableSchema.TableColumn colvarPrimaryTypeId = new TableSchema.TableColumn(schema);
				colvarPrimaryTypeId.ColumnName = "PrimaryTypeId";
				colvarPrimaryTypeId.DataType = DbType.Guid;
				colvarPrimaryTypeId.MaxLength = 0;
				colvarPrimaryTypeId.AutoIncrement = false;
				colvarPrimaryTypeId.IsNullable = true;
				colvarPrimaryTypeId.IsPrimaryKey = false;
				colvarPrimaryTypeId.IsForeignKey = true;
				colvarPrimaryTypeId.IsReadOnly = false;
				colvarPrimaryTypeId.DefaultSetting = @"";
				
					colvarPrimaryTypeId.ForeignKeyTableName = "medianamik_Type";
				schema.Columns.Add(colvarPrimaryTypeId);
				
				TableSchema.TableColumn colvarPrimaryMedianamikControlId = new TableSchema.TableColumn(schema);
				colvarPrimaryMedianamikControlId.ColumnName = "PrimaryMedianamikControlId";
				colvarPrimaryMedianamikControlId.DataType = DbType.Guid;
				colvarPrimaryMedianamikControlId.MaxLength = 0;
				colvarPrimaryMedianamikControlId.AutoIncrement = false;
				colvarPrimaryMedianamikControlId.IsNullable = true;
				colvarPrimaryMedianamikControlId.IsPrimaryKey = false;
				colvarPrimaryMedianamikControlId.IsForeignKey = true;
				colvarPrimaryMedianamikControlId.IsReadOnly = false;
				colvarPrimaryMedianamikControlId.DefaultSetting = @"";
				
					colvarPrimaryMedianamikControlId.ForeignKeyTableName = "medianamik_MedianamikControl";
				schema.Columns.Add(colvarPrimaryMedianamikControlId);
				
				TableSchema.TableColumn colvarPrimaryMedianamikControlWidth = new TableSchema.TableColumn(schema);
				colvarPrimaryMedianamikControlWidth.ColumnName = "PrimaryMedianamikControlWidth";
				colvarPrimaryMedianamikControlWidth.DataType = DbType.AnsiString;
				colvarPrimaryMedianamikControlWidth.MaxLength = 10;
				colvarPrimaryMedianamikControlWidth.AutoIncrement = false;
				colvarPrimaryMedianamikControlWidth.IsNullable = true;
				colvarPrimaryMedianamikControlWidth.IsPrimaryKey = false;
				colvarPrimaryMedianamikControlWidth.IsForeignKey = false;
				colvarPrimaryMedianamikControlWidth.IsReadOnly = false;
				colvarPrimaryMedianamikControlWidth.DefaultSetting = @"";
				colvarPrimaryMedianamikControlWidth.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPrimaryMedianamikControlWidth);
				
				TableSchema.TableColumn colvarPrimaryMedianamikControlHeight = new TableSchema.TableColumn(schema);
				colvarPrimaryMedianamikControlHeight.ColumnName = "PrimaryMedianamikControlHeight";
				colvarPrimaryMedianamikControlHeight.DataType = DbType.Int32;
				colvarPrimaryMedianamikControlHeight.MaxLength = 0;
				colvarPrimaryMedianamikControlHeight.AutoIncrement = false;
				colvarPrimaryMedianamikControlHeight.IsNullable = true;
				colvarPrimaryMedianamikControlHeight.IsPrimaryKey = false;
				colvarPrimaryMedianamikControlHeight.IsForeignKey = false;
				colvarPrimaryMedianamikControlHeight.IsReadOnly = false;
				colvarPrimaryMedianamikControlHeight.DefaultSetting = @"";
				colvarPrimaryMedianamikControlHeight.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPrimaryMedianamikControlHeight);
				
				TableSchema.TableColumn colvarRoles = new TableSchema.TableColumn(schema);
				colvarRoles.ColumnName = "Roles";
				colvarRoles.DataType = DbType.String;
				colvarRoles.MaxLength = -1;
				colvarRoles.AutoIncrement = false;
				colvarRoles.IsNullable = true;
				colvarRoles.IsPrimaryKey = false;
				colvarRoles.IsForeignKey = false;
				colvarRoles.IsReadOnly = false;
				colvarRoles.DefaultSetting = @"";
				colvarRoles.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRoles);
				
				TableSchema.TableColumn colvarMaxLength = new TableSchema.TableColumn(schema);
				colvarMaxLength.ColumnName = "MaxLength";
				colvarMaxLength.DataType = DbType.Int16;
				colvarMaxLength.MaxLength = 0;
				colvarMaxLength.AutoIncrement = false;
				colvarMaxLength.IsNullable = true;
				colvarMaxLength.IsPrimaryKey = false;
				colvarMaxLength.IsForeignKey = false;
				colvarMaxLength.IsReadOnly = false;
				colvarMaxLength.DefaultSetting = @"";
				colvarMaxLength.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMaxLength);
				
				TableSchema.TableColumn colvarMinLength = new TableSchema.TableColumn(schema);
				colvarMinLength.ColumnName = "MinLength";
				colvarMinLength.DataType = DbType.Int16;
				colvarMinLength.MaxLength = 0;
				colvarMinLength.AutoIncrement = false;
				colvarMinLength.IsNullable = true;
				colvarMinLength.IsPrimaryKey = false;
				colvarMinLength.IsForeignKey = false;
				colvarMinLength.IsReadOnly = false;
				colvarMinLength.DefaultSetting = @"";
				colvarMinLength.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMinLength);
				
				TableSchema.TableColumn colvarDataTypeId = new TableSchema.TableColumn(schema);
				colvarDataTypeId.ColumnName = "DataTypeId";
				colvarDataTypeId.DataType = DbType.Guid;
				colvarDataTypeId.MaxLength = 0;
				colvarDataTypeId.AutoIncrement = false;
				colvarDataTypeId.IsNullable = false;
				colvarDataTypeId.IsPrimaryKey = false;
				colvarDataTypeId.IsForeignKey = false;
				colvarDataTypeId.IsReadOnly = false;
				
						colvarDataTypeId.DefaultSetting = @"('195f6f67-f42d-428b-be3e-ad8762cde76f')";
				colvarDataTypeId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDataTypeId);
				
				TableSchema.TableColumn colvarPrimaryDataTypeId = new TableSchema.TableColumn(schema);
				colvarPrimaryDataTypeId.ColumnName = "PrimaryDataTypeId";
				colvarPrimaryDataTypeId.DataType = DbType.Guid;
				colvarPrimaryDataTypeId.MaxLength = 0;
				colvarPrimaryDataTypeId.AutoIncrement = false;
				colvarPrimaryDataTypeId.IsNullable = true;
				colvarPrimaryDataTypeId.IsPrimaryKey = false;
				colvarPrimaryDataTypeId.IsForeignKey = false;
				colvarPrimaryDataTypeId.IsReadOnly = false;
				colvarPrimaryDataTypeId.DefaultSetting = @"";
				colvarPrimaryDataTypeId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPrimaryDataTypeId);
				
				TableSchema.TableColumn colvarDescription = new TableSchema.TableColumn(schema);
				colvarDescription.ColumnName = "Description";
				colvarDescription.DataType = DbType.String;
				colvarDescription.MaxLength = -1;
				colvarDescription.AutoIncrement = false;
				colvarDescription.IsNullable = true;
				colvarDescription.IsPrimaryKey = false;
				colvarDescription.IsForeignKey = false;
				colvarDescription.IsReadOnly = false;
				colvarDescription.DefaultSetting = @"";
				colvarDescription.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDescription);
				
				TableSchema.TableColumn colvarTreeRootNodeId = new TableSchema.TableColumn(schema);
				colvarTreeRootNodeId.ColumnName = "TreeRootNodeId";
				colvarTreeRootNodeId.DataType = DbType.Guid;
				colvarTreeRootNodeId.MaxLength = 0;
				colvarTreeRootNodeId.AutoIncrement = false;
				colvarTreeRootNodeId.IsNullable = true;
				colvarTreeRootNodeId.IsPrimaryKey = false;
				colvarTreeRootNodeId.IsForeignKey = false;
				colvarTreeRootNodeId.IsReadOnly = false;
				colvarTreeRootNodeId.DefaultSetting = @"";
				colvarTreeRootNodeId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTreeRootNodeId);
				
				TableSchema.TableColumn colvarPrimaryTreeRootNodeId = new TableSchema.TableColumn(schema);
				colvarPrimaryTreeRootNodeId.ColumnName = "PrimaryTreeRootNodeId";
				colvarPrimaryTreeRootNodeId.DataType = DbType.Guid;
				colvarPrimaryTreeRootNodeId.MaxLength = 0;
				colvarPrimaryTreeRootNodeId.AutoIncrement = false;
				colvarPrimaryTreeRootNodeId.IsNullable = true;
				colvarPrimaryTreeRootNodeId.IsPrimaryKey = false;
				colvarPrimaryTreeRootNodeId.IsForeignKey = false;
				colvarPrimaryTreeRootNodeId.IsReadOnly = false;
				colvarPrimaryTreeRootNodeId.DefaultSetting = @"";
				colvarPrimaryTreeRootNodeId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPrimaryTreeRootNodeId);
				
				TableSchema.TableColumn colvarIsDeleted = new TableSchema.TableColumn(schema);
				colvarIsDeleted.ColumnName = "IsDeleted";
				colvarIsDeleted.DataType = DbType.Boolean;
				colvarIsDeleted.MaxLength = 0;
				colvarIsDeleted.AutoIncrement = false;
				colvarIsDeleted.IsNullable = false;
				colvarIsDeleted.IsPrimaryKey = false;
				colvarIsDeleted.IsForeignKey = false;
				colvarIsDeleted.IsReadOnly = false;
				
						colvarIsDeleted.DefaultSetting = @"((0))";
				colvarIsDeleted.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsDeleted);
				
				TableSchema.TableColumn colvarIsGenerated = new TableSchema.TableColumn(schema);
				colvarIsGenerated.ColumnName = "IsGenerated";
				colvarIsGenerated.DataType = DbType.Boolean;
				colvarIsGenerated.MaxLength = 0;
				colvarIsGenerated.AutoIncrement = false;
				colvarIsGenerated.IsNullable = false;
				colvarIsGenerated.IsPrimaryKey = false;
				colvarIsGenerated.IsForeignKey = false;
				colvarIsGenerated.IsReadOnly = false;
				
						colvarIsGenerated.DefaultSetting = @"((1))";
				colvarIsGenerated.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsGenerated);
				
				TableSchema.TableColumn colvarRelationshipId = new TableSchema.TableColumn(schema);
				colvarRelationshipId.ColumnName = "RelationshipId";
				colvarRelationshipId.DataType = DbType.Int32;
				colvarRelationshipId.MaxLength = 0;
				colvarRelationshipId.AutoIncrement = false;
				colvarRelationshipId.IsNullable = false;
				colvarRelationshipId.IsPrimaryKey = false;
				colvarRelationshipId.IsForeignKey = false;
				colvarRelationshipId.IsReadOnly = false;
				
						colvarRelationshipId.DefaultSetting = @"((0))";
				colvarRelationshipId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRelationshipId);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["MedianamikProvider"].AddSchema("medianamik_Property",schema);
			}
		}
		#endregion
		
		#region Props
		  
		[XmlAttribute("PropertyId")]
		[Bindable(true)]
		public Guid PropertyId 
		{
			get { return GetColumnValue<Guid>(Columns.PropertyId); }
			set { SetColumnValue(Columns.PropertyId, value); }
		}
		  
		[XmlAttribute("TypeId")]
		[Bindable(true)]
		public Guid TypeId 
		{
			get { return GetColumnValue<Guid>(Columns.TypeId); }
			set { SetColumnValue(Columns.TypeId, value); }
		}
		  
		[XmlAttribute("Name")]
		[Bindable(true)]
		public string Name 
		{
			get { return GetColumnValue<string>(Columns.Name); }
			set { SetColumnValue(Columns.Name, value); }
		}
		  
		[XmlAttribute("HaveTooltip")]
		[Bindable(true)]
		public bool HaveTooltip 
		{
			get { return GetColumnValue<bool>(Columns.HaveTooltip); }
			set { SetColumnValue(Columns.HaveTooltip, value); }
		}
		  
		[XmlAttribute("IsLanguageNeutral")]
		[Bindable(true)]
		public bool IsLanguageNeutral 
		{
			get { return GetColumnValue<bool>(Columns.IsLanguageNeutral); }
			set { SetColumnValue(Columns.IsLanguageNeutral, value); }
		}
		  
		[XmlAttribute("IsRequired")]
		[Bindable(true)]
		public bool IsRequired 
		{
			get { return GetColumnValue<bool>(Columns.IsRequired); }
			set { SetColumnValue(Columns.IsRequired, value); }
		}
		  
		[XmlAttribute("IsUnique")]
		[Bindable(true)]
		public bool IsUnique 
		{
			get { return GetColumnValue<bool>(Columns.IsUnique); }
			set { SetColumnValue(Columns.IsUnique, value); }
		}
		  
		[XmlAttribute("ValidationRegex")]
		[Bindable(true)]
		public string ValidationRegex 
		{
			get { return GetColumnValue<string>(Columns.ValidationRegex); }
			set { SetColumnValue(Columns.ValidationRegex, value); }
		}
		  
		[XmlAttribute("GroupName")]
		[Bindable(true)]
		public string GroupName 
		{
			get { return GetColumnValue<string>(Columns.GroupName); }
			set { SetColumnValue(Columns.GroupName, value); }
		}
		  
		[XmlAttribute("Flags")]
		[Bindable(true)]
		public int Flags 
		{
			get { return GetColumnValue<int>(Columns.Flags); }
			set { SetColumnValue(Columns.Flags, value); }
		}
		  
		[XmlAttribute("MedianamikControlId")]
		[Bindable(true)]
		public Guid? MedianamikControlId 
		{
			get { return GetColumnValue<Guid?>(Columns.MedianamikControlId); }
			set { SetColumnValue(Columns.MedianamikControlId, value); }
		}
		  
		[XmlAttribute("MedianamikControlWidth")]
		[Bindable(true)]
		public string MedianamikControlWidth 
		{
			get { return GetColumnValue<string>(Columns.MedianamikControlWidth); }
			set { SetColumnValue(Columns.MedianamikControlWidth, value); }
		}
		  
		[XmlAttribute("MedianamikControlHeight")]
		[Bindable(true)]
		public int? MedianamikControlHeight 
		{
			get { return GetColumnValue<int?>(Columns.MedianamikControlHeight); }
			set { SetColumnValue(Columns.MedianamikControlHeight, value); }
		}
		  
		[XmlAttribute("Position")]
		[Bindable(true)]
		public short Position 
		{
			get { return GetColumnValue<short>(Columns.Position); }
			set { SetColumnValue(Columns.Position, value); }
		}
		  
		[XmlAttribute("PrimaryPropertyId")]
		[Bindable(true)]
		public Guid? PrimaryPropertyId 
		{
			get { return GetColumnValue<Guid?>(Columns.PrimaryPropertyId); }
			set { SetColumnValue(Columns.PrimaryPropertyId, value); }
		}
		  
		[XmlAttribute("PrimaryTypeId")]
		[Bindable(true)]
		public Guid? PrimaryTypeId 
		{
			get { return GetColumnValue<Guid?>(Columns.PrimaryTypeId); }
			set { SetColumnValue(Columns.PrimaryTypeId, value); }
		}
		  
		[XmlAttribute("PrimaryMedianamikControlId")]
		[Bindable(true)]
		public Guid? PrimaryMedianamikControlId 
		{
			get { return GetColumnValue<Guid?>(Columns.PrimaryMedianamikControlId); }
			set { SetColumnValue(Columns.PrimaryMedianamikControlId, value); }
		}
		  
		[XmlAttribute("PrimaryMedianamikControlWidth")]
		[Bindable(true)]
		public string PrimaryMedianamikControlWidth 
		{
			get { return GetColumnValue<string>(Columns.PrimaryMedianamikControlWidth); }
			set { SetColumnValue(Columns.PrimaryMedianamikControlWidth, value); }
		}
		  
		[XmlAttribute("PrimaryMedianamikControlHeight")]
		[Bindable(true)]
		public int? PrimaryMedianamikControlHeight 
		{
			get { return GetColumnValue<int?>(Columns.PrimaryMedianamikControlHeight); }
			set { SetColumnValue(Columns.PrimaryMedianamikControlHeight, value); }
		}
		  
		[XmlAttribute("Roles")]
		[Bindable(true)]
		public string Roles 
		{
			get { return GetColumnValue<string>(Columns.Roles); }
			set { SetColumnValue(Columns.Roles, value); }
		}
		  
		[XmlAttribute("MaxLength")]
		[Bindable(true)]
		public short? MaxLength 
		{
			get { return GetColumnValue<short?>(Columns.MaxLength); }
			set { SetColumnValue(Columns.MaxLength, value); }
		}
		  
		[XmlAttribute("MinLength")]
		[Bindable(true)]
		public short? MinLength 
		{
			get { return GetColumnValue<short?>(Columns.MinLength); }
			set { SetColumnValue(Columns.MinLength, value); }
		}
		  
		[XmlAttribute("DataTypeId")]
		[Bindable(true)]
		public Guid DataTypeId 
		{
			get { return GetColumnValue<Guid>(Columns.DataTypeId); }
			set { SetColumnValue(Columns.DataTypeId, value); }
		}
		  
		[XmlAttribute("PrimaryDataTypeId")]
		[Bindable(true)]
		public Guid? PrimaryDataTypeId 
		{
			get { return GetColumnValue<Guid?>(Columns.PrimaryDataTypeId); }
			set { SetColumnValue(Columns.PrimaryDataTypeId, value); }
		}
		  
		[XmlAttribute("Description")]
		[Bindable(true)]
		public string Description 
		{
			get { return GetColumnValue<string>(Columns.Description); }
			set { SetColumnValue(Columns.Description, value); }
		}
		  
		[XmlAttribute("TreeRootNodeId")]
		[Bindable(true)]
		public Guid? TreeRootNodeId 
		{
			get { return GetColumnValue<Guid?>(Columns.TreeRootNodeId); }
			set { SetColumnValue(Columns.TreeRootNodeId, value); }
		}
		  
		[XmlAttribute("PrimaryTreeRootNodeId")]
		[Bindable(true)]
		public Guid? PrimaryTreeRootNodeId 
		{
			get { return GetColumnValue<Guid?>(Columns.PrimaryTreeRootNodeId); }
			set { SetColumnValue(Columns.PrimaryTreeRootNodeId, value); }
		}
		  
		[XmlAttribute("IsDeleted")]
		[Bindable(true)]
		public bool IsDeleted 
		{
			get { return GetColumnValue<bool>(Columns.IsDeleted); }
			set { SetColumnValue(Columns.IsDeleted, value); }
		}
		  
		[XmlAttribute("IsGenerated")]
		[Bindable(true)]
		public bool IsGenerated 
		{
			get { return GetColumnValue<bool>(Columns.IsGenerated); }
			set { SetColumnValue(Columns.IsGenerated, value); }
		}
		  
		[XmlAttribute("RelationshipId")]
		[Bindable(true)]
		public int RelationshipId 
		{
			get { return GetColumnValue<int>(Columns.RelationshipId); }
			set { SetColumnValue(Columns.RelationshipId, value); }
		}
		
		#endregion
		
		
		#region PrimaryKey Methods		
		
        protected override void SetPrimaryKey(object oValue)
        {
            base.SetPrimaryKey(oValue);
            
            SetPKValues();
        }
        
		
		private Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection colChildPropertyXRecords;
		public Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection ChildPropertyXRecords()
		{
			if(colChildPropertyXRecords == null)
			{
				colChildPropertyXRecords = new Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection().Where(PropertyX.Columns.PrimaryPropertyId, PropertyId).Load();
				colChildPropertyXRecords.ListChanged += new ListChangedEventHandler(colChildPropertyXRecords_ListChanged);
			}
			return colChildPropertyXRecords;
		}
				
		void colChildPropertyXRecords_ListChanged(object sender, ListChangedEventArgs e)
		{
            if (e.ListChangedType == ListChangedType.ItemAdded)
            {
		        // Set foreign key value
		        colChildPropertyXRecords[e.NewIndex].PrimaryPropertyId = PropertyId;
				colChildPropertyXRecords.ListChanged += new ListChangedEventHandler(colChildPropertyXRecords_ListChanged);
            }
		}
		#endregion
		
			
		
		#region ForeignKey Properties
		
		/// <summary>
		/// Returns a PropertyX ActiveRecord object related to this PropertyX
		/// 
		/// </summary>
		public Medianamik.Core.DAL.SubSonicDAL.PropertyX ParentPropertyX
		{
			get { return Medianamik.Core.DAL.SubSonicDAL.PropertyX.FetchByID(this.PrimaryPropertyId); }
			set { SetColumnValue("PrimaryPropertyId", value.PropertyId); }
		}
		
		
		#endregion
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(Guid varPropertyId,Guid varTypeId,string varName,bool varHaveTooltip,bool varIsLanguageNeutral,bool varIsRequired,bool varIsUnique,string varValidationRegex,string varGroupName,int varFlags,Guid? varMedianamikControlId,string varMedianamikControlWidth,int? varMedianamikControlHeight,short varPosition,Guid? varPrimaryPropertyId,Guid? varPrimaryTypeId,Guid? varPrimaryMedianamikControlId,string varPrimaryMedianamikControlWidth,int? varPrimaryMedianamikControlHeight,string varRoles,short? varMaxLength,short? varMinLength,Guid varDataTypeId,Guid? varPrimaryDataTypeId,string varDescription,Guid? varTreeRootNodeId,Guid? varPrimaryTreeRootNodeId,bool varIsDeleted,bool varIsGenerated,int varRelationshipId)
		{
			PropertyX item = new PropertyX();
			
			item.PropertyId = varPropertyId;
			
			item.TypeId = varTypeId;
			
			item.Name = varName;
			
			item.HaveTooltip = varHaveTooltip;
			
			item.IsLanguageNeutral = varIsLanguageNeutral;
			
			item.IsRequired = varIsRequired;
			
			item.IsUnique = varIsUnique;
			
			item.ValidationRegex = varValidationRegex;
			
			item.GroupName = varGroupName;
			
			item.Flags = varFlags;
			
			item.MedianamikControlId = varMedianamikControlId;
			
			item.MedianamikControlWidth = varMedianamikControlWidth;
			
			item.MedianamikControlHeight = varMedianamikControlHeight;
			
			item.Position = varPosition;
			
			item.PrimaryPropertyId = varPrimaryPropertyId;
			
			item.PrimaryTypeId = varPrimaryTypeId;
			
			item.PrimaryMedianamikControlId = varPrimaryMedianamikControlId;
			
			item.PrimaryMedianamikControlWidth = varPrimaryMedianamikControlWidth;
			
			item.PrimaryMedianamikControlHeight = varPrimaryMedianamikControlHeight;
			
			item.Roles = varRoles;
			
			item.MaxLength = varMaxLength;
			
			item.MinLength = varMinLength;
			
			item.DataTypeId = varDataTypeId;
			
			item.PrimaryDataTypeId = varPrimaryDataTypeId;
			
			item.Description = varDescription;
			
			item.TreeRootNodeId = varTreeRootNodeId;
			
			item.PrimaryTreeRootNodeId = varPrimaryTreeRootNodeId;
			
			item.IsDeleted = varIsDeleted;
			
			item.IsGenerated = varIsGenerated;
			
			item.RelationshipId = varRelationshipId;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(Guid varPropertyId,Guid varTypeId,string varName,bool varHaveTooltip,bool varIsLanguageNeutral,bool varIsRequired,bool varIsUnique,string varValidationRegex,string varGroupName,int varFlags,Guid? varMedianamikControlId,string varMedianamikControlWidth,int? varMedianamikControlHeight,short varPosition,Guid? varPrimaryPropertyId,Guid? varPrimaryTypeId,Guid? varPrimaryMedianamikControlId,string varPrimaryMedianamikControlWidth,int? varPrimaryMedianamikControlHeight,string varRoles,short? varMaxLength,short? varMinLength,Guid varDataTypeId,Guid? varPrimaryDataTypeId,string varDescription,Guid? varTreeRootNodeId,Guid? varPrimaryTreeRootNodeId,bool varIsDeleted,bool varIsGenerated,int varRelationshipId)
		{
			PropertyX item = new PropertyX();
			
				item.PropertyId = varPropertyId;
			
				item.TypeId = varTypeId;
			
				item.Name = varName;
			
				item.HaveTooltip = varHaveTooltip;
			
				item.IsLanguageNeutral = varIsLanguageNeutral;
			
				item.IsRequired = varIsRequired;
			
				item.IsUnique = varIsUnique;
			
				item.ValidationRegex = varValidationRegex;
			
				item.GroupName = varGroupName;
			
				item.Flags = varFlags;
			
				item.MedianamikControlId = varMedianamikControlId;
			
				item.MedianamikControlWidth = varMedianamikControlWidth;
			
				item.MedianamikControlHeight = varMedianamikControlHeight;
			
				item.Position = varPosition;
			
				item.PrimaryPropertyId = varPrimaryPropertyId;
			
				item.PrimaryTypeId = varPrimaryTypeId;
			
				item.PrimaryMedianamikControlId = varPrimaryMedianamikControlId;
			
				item.PrimaryMedianamikControlWidth = varPrimaryMedianamikControlWidth;
			
				item.PrimaryMedianamikControlHeight = varPrimaryMedianamikControlHeight;
			
				item.Roles = varRoles;
			
				item.MaxLength = varMaxLength;
			
				item.MinLength = varMinLength;
			
				item.DataTypeId = varDataTypeId;
			
				item.PrimaryDataTypeId = varPrimaryDataTypeId;
			
				item.Description = varDescription;
			
				item.TreeRootNodeId = varTreeRootNodeId;
			
				item.PrimaryTreeRootNodeId = varPrimaryTreeRootNodeId;
			
				item.IsDeleted = varIsDeleted;
			
				item.IsGenerated = varIsGenerated;
			
				item.RelationshipId = varRelationshipId;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn PropertyIdColumn
        {
            get { return Schema.Columns[0]; }
        }
        
        
        
        public static TableSchema.TableColumn TypeIdColumn
        {
            get { return Schema.Columns[1]; }
        }
        
        
        
        public static TableSchema.TableColumn NameColumn
        {
            get { return Schema.Columns[2]; }
        }
        
        
        
        public static TableSchema.TableColumn HaveTooltipColumn
        {
            get { return Schema.Columns[3]; }
        }
        
        
        
        public static TableSchema.TableColumn IsLanguageNeutralColumn
        {
            get { return Schema.Columns[4]; }
        }
        
        
        
        public static TableSchema.TableColumn IsRequiredColumn
        {
            get { return Schema.Columns[5]; }
        }
        
        
        
        public static TableSchema.TableColumn IsUniqueColumn
        {
            get { return Schema.Columns[6]; }
        }
        
        
        
        public static TableSchema.TableColumn ValidationRegexColumn
        {
            get { return Schema.Columns[7]; }
        }
        
        
        
        public static TableSchema.TableColumn GroupNameColumn
        {
            get { return Schema.Columns[8]; }
        }
        
        
        
        public static TableSchema.TableColumn FlagsColumn
        {
            get { return Schema.Columns[9]; }
        }
        
        
        
        public static TableSchema.TableColumn MedianamikControlIdColumn
        {
            get { return Schema.Columns[10]; }
        }
        
        
        
        public static TableSchema.TableColumn MedianamikControlWidthColumn
        {
            get { return Schema.Columns[11]; }
        }
        
        
        
        public static TableSchema.TableColumn MedianamikControlHeightColumn
        {
            get { return Schema.Columns[12]; }
        }
        
        
        
        public static TableSchema.TableColumn PositionColumn
        {
            get { return Schema.Columns[13]; }
        }
        
        
        
        public static TableSchema.TableColumn PrimaryPropertyIdColumn
        {
            get { return Schema.Columns[14]; }
        }
        
        
        
        public static TableSchema.TableColumn PrimaryTypeIdColumn
        {
            get { return Schema.Columns[15]; }
        }
        
        
        
        public static TableSchema.TableColumn PrimaryMedianamikControlIdColumn
        {
            get { return Schema.Columns[16]; }
        }
        
        
        
        public static TableSchema.TableColumn PrimaryMedianamikControlWidthColumn
        {
            get { return Schema.Columns[17]; }
        }
        
        
        
        public static TableSchema.TableColumn PrimaryMedianamikControlHeightColumn
        {
            get { return Schema.Columns[18]; }
        }
        
        
        
        public static TableSchema.TableColumn RolesColumn
        {
            get { return Schema.Columns[19]; }
        }
        
        
        
        public static TableSchema.TableColumn MaxLengthColumn
        {
            get { return Schema.Columns[20]; }
        }
        
        
        
        public static TableSchema.TableColumn MinLengthColumn
        {
            get { return Schema.Columns[21]; }
        }
        
        
        
        public static TableSchema.TableColumn DataTypeIdColumn
        {
            get { return Schema.Columns[22]; }
        }
        
        
        
        public static TableSchema.TableColumn PrimaryDataTypeIdColumn
        {
            get { return Schema.Columns[23]; }
        }
        
        
        
        public static TableSchema.TableColumn DescriptionColumn
        {
            get { return Schema.Columns[24]; }
        }
        
        
        
        public static TableSchema.TableColumn TreeRootNodeIdColumn
        {
            get { return Schema.Columns[25]; }
        }
        
        
        
        public static TableSchema.TableColumn PrimaryTreeRootNodeIdColumn
        {
            get { return Schema.Columns[26]; }
        }
        
        
        
        public static TableSchema.TableColumn IsDeletedColumn
        {
            get { return Schema.Columns[27]; }
        }
        
        
        
        public static TableSchema.TableColumn IsGeneratedColumn
        {
            get { return Schema.Columns[28]; }
        }
        
        
        
        public static TableSchema.TableColumn RelationshipIdColumn
        {
            get { return Schema.Columns[29]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string PropertyId = @"PropertyId";
			 public static string TypeId = @"TypeId";
			 public static string Name = @"Name";
			 public static string HaveTooltip = @"HaveTooltip";
			 public static string IsLanguageNeutral = @"IsLanguageNeutral";
			 public static string IsRequired = @"IsRequired";
			 public static string IsUnique = @"IsUnique";
			 public static string ValidationRegex = @"ValidationRegex";
			 public static string GroupName = @"GroupName";
			 public static string Flags = @"Flags";
			 public static string MedianamikControlId = @"MedianamikControlId";
			 public static string MedianamikControlWidth = @"MedianamikControlWidth";
			 public static string MedianamikControlHeight = @"MedianamikControlHeight";
			 public static string Position = @"Position";
			 public static string PrimaryPropertyId = @"PrimaryPropertyId";
			 public static string PrimaryTypeId = @"PrimaryTypeId";
			 public static string PrimaryMedianamikControlId = @"PrimaryMedianamikControlId";
			 public static string PrimaryMedianamikControlWidth = @"PrimaryMedianamikControlWidth";
			 public static string PrimaryMedianamikControlHeight = @"PrimaryMedianamikControlHeight";
			 public static string Roles = @"Roles";
			 public static string MaxLength = @"MaxLength";
			 public static string MinLength = @"MinLength";
			 public static string DataTypeId = @"DataTypeId";
			 public static string PrimaryDataTypeId = @"PrimaryDataTypeId";
			 public static string Description = @"Description";
			 public static string TreeRootNodeId = @"TreeRootNodeId";
			 public static string PrimaryTreeRootNodeId = @"PrimaryTreeRootNodeId";
			 public static string IsDeleted = @"IsDeleted";
			 public static string IsGenerated = @"IsGenerated";
			 public static string RelationshipId = @"RelationshipId";
						
		}
		#endregion
		
		#region Update PK Collections
		
        public void SetPKValues()
        {
                if (colChildPropertyXRecords != null)
                {
                    foreach (Medianamik.Core.DAL.SubSonicDAL.PropertyX item in colChildPropertyXRecords)
                    {
                        if (item.PrimaryPropertyId != PropertyId)
                        {
                            item.PrimaryPropertyId = PropertyId;
                        }
                    }
               }
		}
        #endregion
    
        #region Deep Save
		
        public void DeepSave()
        {
            Save();
            
                if (colChildPropertyXRecords != null)
                {
                    colChildPropertyXRecords.SaveAll();
               }
		}
        #endregion
	}
}
